/*
 * Ext JS Library 3.1.0
 * Copyright 2009-2010 iThink Team
 * lingtianlan
 * 2010-4-6
 */
 //alert('load..');
Ext.ux.Question = Ext.extend(Ext.BoxComponent, {
    qType: 0,    // 0 单选题 1 多选题 2 判断题 3 填空题
    order: 1,    // 题序号
    qId: 0,      // 题目ID
    qTitle: '题目',   // 题干
    qBody: [{ Label: 'test:A', Content: 'test:Content'}],    // 选项
    tplChoice: new Ext.Template("<li class='x-question-choice'><input type='{0}' name='{1}' value='{2}'/>", "{3}.{4}</li>"),
    tplJudge: new Ext.Template("<li class='x-question-choice'><input type='radio' name='{0}' value='1'/>正确 ", "<input type='radio' name='{0}' value='0'/>错误</li>"),
    tplFillBlank: new Ext.Template("<li class='x-question-blank'>{0}<input type='text' name='{1}' /></li>"),
    
    onRender: function() {
        Ext.ux.Question.superclass.onRender.apply(this, arguments);
        Ext.DomHelper.append(this.el, { html: '<div>' + this.order + '.' + this.qTitle + '</div>', cls: 'x-question-title' });
        var choicePad = Ext.DomHelper.append(this.el, { tag: 'ul', cls: 'x-question-pad' });

        // 单选题的情况
        if (this.qType == 0) {
            for (var i = 0; i < this.qBody.length; i++) {
                this.tplChoice.append(choicePad, ['radio', this.qId, this.qBody[i].Label, this.qBody[i].Label, this.qBody[i].Content]);
            }
        }

        // 多选题的情况
        if (this.qType == 1) {
            for (var i = 0; i < this.qBody.length; i++) {
                this.tplChoice.append(choicePad, ['checkbox', this.qId, this.qBody[i].Label, this.qBody[i].Label, this.qBody[i].Content]);
            }
        }

        //判断题的情况
        if (this.qType == 2) {
            this.tplJudge.append(choicePad, [this.qId]);
        }

        //填空题的情况
        if (this.qType == 3) {
            this.tplFillBlank.append(choicePad, ['您的答案(多答案请用英文逗号分隔)：', this.qId]);
        }
    }
			

});